<!--
 * @FilePath     : /study_code/vue2.x/custom-event1.html
 * @Description  : 组件上使用 大驼峰写法，例如 myEvent 定义自定义事件名称
 * @Date         : 2025-05-02 17:08:08
 * @Author       : Fang YingGui
 * @LastEditors  : fangyinggui 18715384437@163.com
 * @LastEditTime : 2025-05-02 17:08:18
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>documentName</title>
    <link rel="stylesheet" href="" />
  </head>
  <body>
    <div id="app">
      <child1 @click="handle2" @myEvent="myEventHandle1"></child1>
    </div>

    <script src="/vue/dist/vue.min.js"></script>
    <script src="./common.js"></script>
    <script>
      const Child1 = {
        template: `<button @click="childHandle1">子组件-按钮</button>`,
        methods: {
          childHandle1() {
            console.log('z 子组件事件')
            this.$emit('myEvent')
          },
        },
      }

      var vm = new Vue({
        el: '#app',
        components: {
          Child1,
        },
        data: function () {
          return {}
        },
        methods: {
          myEventHandle1() {
            console.log('x 父组件上监听的自定义事件')
          },
          handle2() {
            console.log('y 父组件点击')
          },
        },
      })
    </script>
  </body>
</html>
